package miracle.joker.design.chain_of_responsibility;

import java.util.Arrays;
import java.util.List;

public class FileTypeChecker implements Uploader {
    private List<String> ALLOWED_TYPES = Arrays.asList("jpg", "png", "gif");
    private Uploader next;

    public void setNext(Uploader uploader) {
        this.next = uploader;
    }

    @Override
    public void upload(File file) {
        if (!ALLOWED_TYPES.contains(file.getType())) {
            System.out.println("File type is not allowed.");
        } else if (next != null) {
            System.out.println("FTC");
            next.upload(file);
        } else {
            System.out.println("Upload successful.(FTC)");
        }
    }
}
